/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2016 All Rights Reserved.
 */
package com.alipay.study.common.contact.security;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import com.alipay.study.common.util.string.StringUtil;

/**
 * 
 * @author wb-qlj205528
 * @version $Id: SecurityWebContact.java, v 0.1 2016年11月15日 上午10:28:33 wb-qlj205528 Exp $
 */
@Component
@PropertySource(value = "classpath:security-web.properties", ignoreResourceNotFound = true)
@ConfigurationProperties(prefix = "security.web")
public class SecurityWebContact {

    /**
     * 分隔符
     */
    private String   strSplit;

    /**
     * 登录的url
     */
    private String   loginPage;

    /**
     * 登录的url标识
     */
    private String   loginProcessingUrl;
    /**
     * 不被权限限制的url
     */
    private String[] excuteMatchers;
    /**
     * 除了excuteMatchers之外的所有url默认必须具有的角色
     */
    private String   defaultRole;
    /**
     * 默认登录成功之后跳转的url
     */
    private String   defaultSuccessUrl;
    /**
     * 退出标识的url
     */
    private String   logoutUrl;
    /**
     * 退出成功跳转的页面
     */
    private String   logoutSuccessUrl;

    /**
     * public key pinning 提交url
     */
    private String   publicKeyPinningReportUrl;
    /**
     * public key pinning sha256 pins
     */
    private String[] publicKeyPinningSha256Pins;
    /**
     * public key pinning report only
     */
    private boolean  publicKeyPinningReportOnly;
    /**
     * Content-Security-Policy
     */
    private String   contentSecurityPolicy;
    /**
     * Allowrd Origins
     */
    private String[] allowedOrigins;
    /**
     * Allowrd Method
     */
    private String[] allowedMethod;
    /**
     * Cord  Configuration Root
     */
    private String   corsConfigurationRoot;
    /**
     * 请求param中的用户名的name
     */
    private String   usernamePram;
    /**
     * 请求param中的密码的name
     */
    private String   passwordParam;

    /**
     * Getter method for property <tt>usernamePram</tt>.
     * 
     * @return property value of usernamePram
     */
    public String getUsernameParam() {
        return usernamePram;
    }

    /**
     * Setter method for property <tt>usernamePram</tt>.
     * 
     * @param usernamePram value to be assigned to property usernamePram
     */
    public void setUsernameParam(String usernamePram) {
        this.usernamePram = usernamePram;
    }

    /**
     * Getter method for property <tt>passwordParam</tt>.
     * 
     * @return property value of password
     */
    public String getPasswordParam() {
        return passwordParam;
    }

    /**
     * Setter method for property <tt>passwordParam</tt>.
     * 
     * @param passwordParam value to be assigned to property passwordParam
     */
    public void setPasswordParam(String passwordParam) {
        this.passwordParam = passwordParam;
    }

    /**
     * Getter method for property <tt>strSplit</tt>.
     * 
     * @return property value of strSplit
     */
    public String getStrSplit() {
        return strSplit;
    }

    /**
     * Setter method for property <tt>strSplit</tt>.
     * 
     * @param strSplit value to be assigned to property strSplit
     */
    public void setStrSplit(String strSplit) {
        this.strSplit = strSplit;
    }

    /**
     * Getter method for property <tt>loginPage</tt>.
     * 
     * @return property value of loginPage
     */
    public String getLoginPage() {
        return loginPage;
    }

    /**
     * Setter method for property <tt>loginPage</tt>.
     * 
     * @param loginPage value to be assigned to property loginPage
     */
    public void setLoginPage(String loginPage) {
        this.loginPage = loginPage;
    }

    /**
     * Getter method for property <tt>loginProcessingUrl</tt>.
     * 
     * @return property value of loginProcessingUrl
     */
    public String getLoginProcessingUrl() {
        return loginProcessingUrl;
    }

    /**
     * Setter method for property <tt>loginProcessingUrl</tt>.
     * 
     * @param loginProcessingUrl value to be assigned to property loginProcessingUrl
     */
    public void setLoginProcessingUrl(String loginProcessingUrl) {
        this.loginProcessingUrl = loginProcessingUrl;
    }

    /**
     * Getter method for property <tt>excuteMatchers</tt>.
     * 
     * @return property value of excuteMatchers
     */
    public String[] getExcuteMatchers() {
        return excuteMatchers;
    }

    /**
     * Setter method for property <tt>excuteMatchers</tt>.
     * 
     * @param excuteMatchers value to be assigned to property excuteMatchers
     */
    public void setExcuteMatchers(String excuteMatchers) {
        if (StringUtil.isBlank(excuteMatchers)) {
            return;
        }
        if (excuteMatchers.contains(getStrSplit())) {
            this.excuteMatchers = excuteMatchers.split(getStrSplit());
        } else {
            this.excuteMatchers = new String[] { excuteMatchers };
        }
    }

    /**
     * Setter method for property <tt>excuteMatchers</tt>.
     * 
     * @param excuteMatchers value to be assigned to property excuteMatchers
     */
    public void setExcuteMatchers(String[] excuteMatchers) {
        this.excuteMatchers = excuteMatchers;
    }

    /**
     * Getter method for property <tt>defaultRole</tt>.
     * 
     * @return property value of defaultRole
     */
    public String getDefaultRole() {
        return defaultRole;
    }

    /**
     * Setter method for property <tt>defaultRole</tt>.
     * 
     * @param defaultRole value to be assigned to property defaultRole
     */
    public void setDefaultRole(String defaultRole) {
        this.defaultRole = defaultRole;
    }

    /**
     * Getter method for property <tt>defaultSuccessUrl</tt>.
     * 
     * @return property value of defaultSuccessUrl
     */
    public String getDefaultSuccessUrl() {
        return defaultSuccessUrl;
    }

    /**
     * Setter method for property <tt>defaultSuccessUrl</tt>.
     * 
     * @param defaultSuccessUrl value to be assigned to property defaultSuccessUrl
     */
    public void setDefaultSuccessUrl(String defaultSuccessUrl) {
        this.defaultSuccessUrl = defaultSuccessUrl;
    }

    /**
     * Getter method for property <tt>logoutUrl</tt>.
     * 
     * @return property value of logoutUrl
     */
    public String getLogoutUrl() {
        return logoutUrl;
    }

    /**
     * Setter method for property <tt>logoutUrl</tt>.
     * 
     * @param logoutUrl value to be assigned to property logoutUrl
     */
    public void setLogoutUrl(String logoutUrl) {
        this.logoutUrl = logoutUrl;
    }

    /**
     * Getter method for property <tt>logoutSuccessUrl</tt>.
     * 
     * @return property value of logoutSuccessUrl
     */
    public String getLogoutSuccessUrl() {
        return logoutSuccessUrl;
    }

    /**
     * Setter method for property <tt>logoutSuccessUrl</tt>.
     * 
     * @param logoutSuccessUrl value to be assigned to property logoutSuccessUrl
     */
    public void setLogoutSuccessUrl(String logoutSuccessUrl) {
        this.logoutSuccessUrl = logoutSuccessUrl;
    }

    /**
     * Getter method for property <tt>publicKeyPinningReportUrl</tt>.
     * 
     * @return property value of publicKeyPinningReportUrl
     */
    public String getPublicKeyPinningReportUrl() {
        return publicKeyPinningReportUrl;
    }

    /**
     * Setter method for property <tt>publicKeyPinningReportUrl</tt>.
     * 
     * @param publicKeyPinningReportUrl value to be assigned to property publicKeyPinningReportUrl
     */
    public void setPublicKeyPinningReportUrl(String publicKeyPinningReportUrl) {
        this.publicKeyPinningReportUrl = publicKeyPinningReportUrl;
    }

    /**
     * Getter method for property <tt>publicKeyPinningSha256Pins</tt>.
     * 
     * @return property value of publicKeyPinningSha256Pins
     */
    public String[] getPublicKeyPinningSha256Pins() {
        return publicKeyPinningSha256Pins;
    }

    /**
     * Setter method for property <tt>publicKeyPinningSha256Pins</tt>.
     * 
     * @param publicKeyPinningSha256Pins value to be assigned to property publicKeyPinningSha256Pins
     */
    public void setPublicKeyPinningSha256Pins(String[] publicKeyPinningSha256Pins) {
        this.publicKeyPinningSha256Pins = publicKeyPinningSha256Pins;
    }

    /**
     * Setter method for property <tt>publicKeyPinningSha256Pins</tt>.
     * 
     * @param publicKeyPinningSha256Pins value to be assigned to property publicKeyPinningSha256Pins
     */
    public void setPublicKeyPinningSha256Pins(String publicKeyPinningSha256Pins) {
        if (StringUtil.isBlank(publicKeyPinningSha256Pins)) {
            return;
        }
        if (publicKeyPinningSha256Pins.contains(getStrSplit())) {
            this.publicKeyPinningSha256Pins = publicKeyPinningSha256Pins.split(getStrSplit());
        } else {
            this.publicKeyPinningSha256Pins = new String[] { publicKeyPinningSha256Pins };
        }
    }

    /**
     * Getter method for property <tt>publicKeyPinningReportOnly</tt>.
     * 
     * @return property value of publicKeyPinningReportOnly
     */
    public boolean getPublicKeyPinningReportOnly() {
        return publicKeyPinningReportOnly;
    }

    /**
     * Setter method for property <tt>publicKeyPinningReportOnly</tt>.
     * 
     * @param publicKeyPinningReportOnly value to be assigned to property publicKeyPinningReportOnly
     */
    public void setPublicKeyPinningReportOnly(String publicKeyPinningReportOnly) {
        this.publicKeyPinningReportOnly = Boolean.valueOf(publicKeyPinningReportOnly);
    }

    /**
     * Getter method for property <tt>contentSecurityPolicy</tt>.
     * 
     * @return property value of contentSecurityPolicy
     */
    public String getContentSecurityPolicy() {
        return contentSecurityPolicy;
    }

    /**
     * Setter method for property <tt>contentSecurityPolicy</tt>.
     * 
     * @param contentSecurityPolicy value to be assigned to property contentSecurityPolicy
     */
    public void setContentSecurityPolicy(String contentSecurityPolicy) {
        this.contentSecurityPolicy = contentSecurityPolicy;
    }

    /**
     * Getter method for property <tt>allowedOrigins</tt>.
     * 
     * @return property value of allowedOrigins
     */
    public String[] getAllowedOrigins() {
        return allowedOrigins;
    }

    /**
     * Setter method for property <tt>allowedOrigins</tt>.
     * 
     * @param allowedOrigins value to be assigned to property allowedOrigins
     */
    public void setAllowedOrigins(String[] allowedOrigins) {
        this.allowedOrigins = allowedOrigins;
    }

    /**
     * Getter method for property <tt>allowedMethod</tt>.
     * 
     * @return property value of allowedMethod
     */
    public String[] getAllowedMethod() {
        return allowedMethod;
    }

    /**
     * Setter method for property <tt>allowedMethod</tt>.
     * 
     * @param allowedMethod value to be assigned to property allowedMethod
     */
    public void setAllowedMethod(String[] allowedMethod) {
        this.allowedMethod = allowedMethod;
    }

    /**
     * Setter method for property <tt>allowedMethod</tt>.
     * 
     * @param allowedMethod value to be assigned to property allowedMethod
     */
    public void setAllowedMethod(String allowedMethod) {
        if (StringUtil.isBlank(allowedMethod)) {
            return;
        }
        if (allowedMethod.contains(getStrSplit())) {
            this.allowedMethod = allowedMethod.split(getStrSplit());
        } else {
            this.allowedMethod = new String[] { allowedMethod };
        }
    }

    /**
     * Getter method for property <tt>corsConfigurationRoot</tt>.
     * 
     * @return property value of corsConfigurationRoot
     */
    public String getCorsConfigurationRoot() {
        return corsConfigurationRoot;
    }

    /**
     * Setter method for property <tt>corsConfigurationRoot</tt>.
     * 
     * @param corsConfigurationRoot value to be assigned to property corsConfigurationRoot
     */
    public void setCorsConfigurationRoot(String corsConfigurationRoot) {
        this.corsConfigurationRoot = corsConfigurationRoot;
    }
}
